/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007-2008 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.projects.csv.bean.impl;

import org.springframework.util.StringUtils;

import com.genia.toolbox.projects.csv.bean.MutableFieldDescriptor;
import com.genia.toolbox.projects.csv.enumeration.FieldType;

/**
 * base implementation of a {@link MutableFieldDescriptor}.
 */
public abstract class AbstractFieldDescriptorImpl
    extends AbstractFolderDescriptorLinkableImpl
    implements MutableFieldDescriptor
{

  /**
   * the name of the {@link MutableFieldDescriptor}.
   */
  private String name;

  /**
   * the regular expression that represents a null value.
   */
  private String nullRegularExpression = null;

  /**
   * the type of the current field.
   */
  private FieldType fieldType = FieldType.DEFAULT;

  /**
   * the class of the field.
   */
  private Class<?> fieldClass = String.class;



  /**
   * getter for the name property.
   * 
   * @return the name
   */
  public String getName()
  {
    return name;
  }



  /**
   * setter for the name property.
   * 
   * @param name
   *          the name to set
   */
  public void setName(String name)
  {
    this.name = StringUtils.trimWhitespace(name);
  }



  /**
   * getter for the fieldType property.
   * 
   * @return the fieldType
   */
  public FieldType getFieldType()
  {
    return fieldType;
  }



  /**
   * setter for the fieldType property.
   * 
   * @param fieldType
   *          the fieldType to set
   */
  public void setFieldType(FieldType fieldType)
  {
    this.fieldType = fieldType;
  }



  /**
   * getter for the nullRegularExpression property.
   * 
   * @return the nullRegularExpression
   */
  public String getNullRegularExpression()
  {
    return nullRegularExpression;
  }



  /**
   * setter for the nullRegularExpression property.
   * 
   * @param nullRegularExpression
   *          the nullRegularExpression to set
   */
  public void setNullRegularExpression(String nullRegularExpression)
  {
    this.nullRegularExpression = StringUtils.trimWhitespace(nullRegularExpression);
  }



  /**
   * getter for the fieldClass property.
   * 
   * @return the fieldClass
   */
  public Class<?> getFieldClass()
  {
    return fieldClass;
  }



  /**
   * setter for the fieldClass property.
   * 
   * @param fieldClass
   *          the fieldClass to set
   */
  public void setFieldClass(Class<?> fieldClass)
  {
    this.fieldClass = fieldClass;
  }

}
